package rejaw.api.data
{
	/**This object contains information about a Rejaw conversation (thread).
	 * 
	 * @author Bryan Bartow | bryanbartow@gmail.com | http://www.bryanbartow.com
	 * */
	public class RejawConversation
	{
		public var type         : String;
		public var timeStamp    : String;
		public var userName     : String;
		public var fullName     : String;
		public var state        : String;
		public var cid          : String;
		public var serialNumber : String;
		public var imageURL     : String;
		public var unreadCount  : String;
		public var text         : String;
		public var messages     : Array = new Array();
		
		public function RejawConversation( conversation : Object = null )
		{
			if( conversation != null )
			{
				buildRejawConversation( conversation );
			}
		}
		
		public function buildRejawConversation( conversation : Object ) : void
		{
			type         = conversation.type;
			timeStamp    = conversation.timestamp;
			userName     = conversation.username;
			fullName     = conversation.fullname;
			state        = conversation.state;
			cid          = conversation.cid;
			serialNumber = conversation.serial_number;
			imageURL     = conversation.image_url;
			unreadCount  = conversation.unread;
			text         = conversation.text;
			
			if( conversation.messages != null )
			{
				for( var i : int = 0; i < conversation.messages.length; i++ )
				{
					var tmpMessage : RejawMessage = new RejawMessage( conversation.messages[i] );
					messages.push( tmpMessage );
				}
			}
		}
	}
}